<docs>
  ## 工作经历
</docs>
<template>
  <div>
    <!-- 背景图 -->
    <div class="beijingtu"></div>
    <div class="bg_g">
      <!-- 基本个人信息 -->
      <div class="box1">
        <co-form :model="data" :rules="rules" ref="form">
          <div class="box3">
            <div class="box2 boild">
              <div class="describe">开始时间</div>
              <data-picker prop="gzkssj" v-model="data.gzkssj" class="_date"></data-picker>
            </div>
            <!--时间 -->
            <div class="box2 boild">
              <div class="describe">结束时间</div>
              <data-picker prop="gzjssj" v-model="data.gzjssj" class="_date"></data-picker>
            </div>
            <div class="box2 boild">
              <div class="describe">学校(单位)</div>
              <co-input class="pad_left" prop="dwmc" v-model="data.dwmc" placeholder="请输入"></co-input>
            </div>
            <div class="box2 pad_botm">
              <div class="describe">职务</div>
              <co-input class="pad_left" prop="zw" v-model="data.zw" placeholder="请输入"></co-input>
            </div>
          </div>
          <!-- 职务 -->
        </co-form>
      </div>
    </div>
    <div class="bottom"></div>
    <!-- <div class="h100" style="height:.8rem;"></div> -->
    <!-- 底部保存 -->
    <div class="info-bottom" v-if="this.gzjlid==null">
      <button class="bc" @click="gzjlBc">保&nbsp;&nbsp;存</button>
    </div>
    <div class="info-bottom" v-else>
      <button class="del" @click="gzjldel" style="margin-left:3%">删&nbsp;&nbsp;除</button>
      <button class="bcc" @click="gzjlBc" style="margin-left:5%">修&nbsp;&nbsp;改</button>
    </div>
  </div>
</template>
<script>
import $ from "@/common/js/axios";
import coForm from "@/base/form/form";
import coInput from "@/base/form/input";
import { validator } from "@/common/js/valid";
import { mixinValid } from "@/common/mixins/mixins";
import dataPicker from "@/base/form/dataPicker";
export default {
  components: { coInput, coForm, dataPicker },
  name: "workex",
  mixins: [mixinValid],
  data() {
    return {
      gzjlid: "",
      data: {
        gzllid: "", //类型：String  必有字段  备注：14,full,工作履历ID,true
        gzkssj: "", //类型：String  必有字段  备注：10,date,工作开始时间,false
        gzjssj: "", //类型：String  必有字段  备注：10,date,工作结束时间,false
        dwmc: "", //类型：String  必有字段  备注：64,full,单位名称,false
        zw: "" //类型：String  必有字段  备注：64,full,职务,false
      },
      rules: {
        gzllid: validator('14,"full","工作履历ID",true'),
        gzkssj: validator('15,"full","工作开始时间",false'),
        gzjssj: validator('15,"full","工作结束时间",false'),
        dwmc: validator('64,"full","单位名称",false'),
        zw: validator('64,"full","职务",false')
      }
    };
  },
  computed: {},
  methods: {
    // 保存求职意向接口
    gzjlBc() {
      if (this.data.gzkssj > this.data.gzjssj) {
        this.$alert({
          type: "warning",
          message: "开始时间不能大于结束时间"
        });
        return false;
      } else {
        this.$refs.form.validate(() => {
          this.ggg();
        });
      }
    },
    ggg() {
      $.post("/wdjl/gzjlBc", this.data).then(res => {
        if (res.returnData.executeResult == "1") {
          this.$alert(
            {
              type: "success",
              message: res.returnData.message
            },
            () => {
              this.$router.push({ path: "/cvitae" });
            }
          );
        } else {
          this.$alert({
            type: "warning",
            message: res.returnData.message
          });
        }
      });
    },
    gzjldel() {
      //工作经历删除JSON.stringify(this.id)
      this.$confirm("确认删除本工作经历吗", "提示", {
        cancleBtnText: "取消",
        confirmBtnText: "确认"
      })
        .then(() => {
          $.post("/wdjl/gzjlSc", { gzllid: this.gzjlid }).then(res => {
            if (res.returnData.executeResult == "1") {
              this.$alert(
                {
                  type: "success",
                  message: res.returnData.message
                },
                () => {
                  this.$router.push({ path: "/cvitae" });
                }
              );
            } else {
              this.$alert({
                type: "warning",
                message: res.returnData.message
              });
            }
          });
        })
        .catch(() => {});
    },
    // 工作经历查询
    getgzjlCx() {
      this.$loading = true;
      $.get("/wdjl/gzjlCx?gzllid=" + this.gzjlid).then(res => {
        this.data = res.returnData.gzll;
        this.$loading = false;
      });
    }
  },
  created() {
    // 获取到传过来的参数
    let id = this.$route.query.gzllid;
    this.gzjlid = id;
    if (id) {
      this.getgzjlCx();
    }
  }
};
</script>
<style lang="scss" scoped>
@import "~common/scss/var.scss";
#apply {
  position: absolute;
}
.pad_botm {
  padding-bottom: 15px;
}
.weui-cell_select-after {
  width: 100%;
}
.boild::after {
  content: " ";
  display: inline-block;
  width: 85%;
  border-bottom: 1px solid rgba(229, 229, 229, 1);
  position: absolute;
  top: 110%;
}
._date {
  padding: 15px 0;
}
.box2 {
  position: relative;
  padding-left: 35px;
}
.beijingtu {
  width: 100%;
  height: 880px;
  background: url("../../common/images/beijing.png") no-repeat;
  background-size: 100% 100%;
  position: absolute;
  z-index: -9000;
  margin-top: -210px;
}
.h100 {
  height: 0.8rem;
}
.bottom {
  width: 100%;
  height: 190px;
  background: url("../../common/images/dbg.png") no-repeat;
  background-size: 100%;
  position: fixed;
  bottom: 0;
  // margin-top: 4rem;
}
.bg_g {
  padding: 0 34px;
  overflow: hidden;
  position: relative;
}
.describe {
  font-size: $font-size-base;
  margin: 40px 0 20px 0px;
  color: #666666;
}
.padd {
  font-weight: bold;
  font-size: 32px;
  margin: 20px 0 66px 32px;
  display: block;
  color: #333333;
}
.box1 {
  margin: 40px auto;
  margin-bottom: 3rem;
  background: white;
  border-radius: 4px;
  overflow: hidden;
}
</style>
